<?php

include __DIR__."/IpaParser.php";
include __DIR__."/ApkParser.php";

class parseApp {
    
    /**
     * @desc apk文件解析AndroidManifest
     * @param string $fullName /public/upload/AndroidManifest.xml
     * @return array|bool
     */
    public function parseApk($fullName = '') {
        if(!$fullName) {
            return false;
        }
        $main = new ApkParser();
        $main->open($fullName);
        return [
            'package'     => $main->getPackage(),
            'versionName' => $main->getVersionName(),
            'versionCode' => $main->getVersionCode(),
            'appName'     => $main->getAppName(),
        ];
    
    }
    
    /**
     * @desc apk文件解析AndroidManifest
     * @param string $fullName /public/upload/plist.ipa
     * @return array|bool
     * @throws PListException
     */
    public function parseIpa($fullName = '') {
        if(!$fullName) {
            return false;
        }
        $main = new IpaParser;
        $main->parse($fullName);
        return [
            'package' => $main->getPackage(),
            'version' => $main->getVersion(),
            'appName' => $main->getAppName(),
            'plist' => $main->getPlist(),
        ];
    }
}
